package com.acme.entity;

import com.acme.entity.util.EntityBean;
import java.math.BigDecimal;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;

/**
 *
 * @author alejandro
 */
@Entity
@Table(name = "CASETA", catalog = "carreteras", schema = "dbo")
@NamedQueries({
    @NamedQuery(name = "Caseta.findAll", query = "SELECT c FROM Caseta c"),
    @NamedQuery(name = "Caseta.findById", query = "SELECT c FROM Caseta c WHERE c.id = :id"),
    @NamedQuery(name = "Caseta.findByNombe", query = "SELECT c FROM Caseta c WHERE c.nombe = :nombe"),
    @NamedQuery(name = "Caseta.findByPeaje", query = "SELECT c FROM Caseta c WHERE c.peaje = :peaje"),
    @NamedQuery(name = "Caseta.findByKilometro", query = "SELECT c FROM Caseta c WHERE c.kilometro = :kilometro")})
public class Caseta extends EntityBean<Caseta> {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Column(name = "id", nullable = false)
    private Integer id;
    @Basic(optional = false)
    @Column(name = "nombe", nullable = false, length = 15)
    private String nombe;
    @Basic(optional = false)
    @Column(name = "peaje", nullable = false, precision = 19, scale = 4)
    private BigDecimal peaje;
    @Column(name = "kilometro", length = 15)
    private String kilometro;
    @JoinColumn(name = "tramo", referencedColumnName = "id", nullable = false)
    @ManyToOne(optional = false)
    private Tramo tramo;
    @JoinColumn(name = "tipo", referencedColumnName = "id", nullable = false)
    @ManyToOne(optional = false)
    private TipoCaseta tipoCaseta;
    @JoinColumn(name = "despachador", referencedColumnName = "numero", nullable = false)
    @ManyToOne(optional = false)
    private Empleado empleado;

    public Caseta() {
    }

    public Caseta(Integer id) {
        this.id = id;
    }

    public Caseta(Integer id, String nombe, BigDecimal peaje) {
        this.id = id;
        this.nombe = nombe;
        this.peaje = peaje;
    }

    public Caseta(Integer id, String nombe, BigDecimal peaje, String kilometro, Tramo tramo, TipoCaseta tipoCaseta, Empleado empleado) {
        this.id = id;
        this.nombe = nombe;
        this.peaje = peaje;
        this.kilometro = kilometro;
        this.tramo = tramo;
        this.tipoCaseta = tipoCaseta;
        this.empleado = empleado;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
        support.fireChange();
    }

    public String getNombe() {
        return nombe;
    }

    public void setNombe(String nombe) {
        this.nombe = nombe;
        support.fireChange();
    }

    public BigDecimal getPeaje() {
        return peaje;
    }

    public void setPeaje(BigDecimal peaje) {
        this.peaje = peaje;
        support.fireChange();
    }

    public String getKilometro() {
        return kilometro;
    }

    public void setKilometro(String kilometro) {
        this.kilometro = kilometro;
        support.fireChange();
    }

    public Tramo getTramo() {
        return tramo;
    }

    public void setTramo(Tramo tramo) {
        this.tramo = tramo;
        support.fireChange();
    }

    public TipoCaseta getTipoCaseta() {
        return tipoCaseta;
    }

    public void setTipoCaseta(TipoCaseta tipoCaseta) {
        this.tipoCaseta = tipoCaseta;
        support.fireChange();
    }

    public Empleado getEmpleado() {
        return empleado;
    }

    public void setEmpleado(Empleado empleado) {
        this.empleado = empleado;
        support.fireChange();
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        if (!(object instanceof Caseta)) return false;
        Caseta other = (Caseta) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return String.format("%s km%s (%s)", nombe, kilometro, tramo);
    }

    @Override
    public Caseta clone() {
        return new Caseta(id, nombe, peaje, kilometro, tramo, tipoCaseta, empleado);
    }

    @Override
    public void merge(Caseta other) {
        this.id = other.id;
        this.nombe = other.nombe;
        this.peaje = other.peaje;
        this.kilometro = other.kilometro;
        this.tramo = other.tramo;
        this.tipoCaseta = other.tipoCaseta;
        this.empleado = other.empleado;
    }

}
